#include "./treeviewadapter.h"
#include "./polygondata/polygondata.h"

TreeViewAdapter::TreeViewAdapter()
{
    this->setHorizontalHeaderItem(0, new QStandardItem( "Project" ));
}

void TreeViewAdapter::addFromIterator(QString header, ElementIterator *iterator)
{
    QStandardItem *item = new QStandardItem(header);
    this->appendRow(item);
    QSharedPointer<PolygonData> polygonData = PolygonData::instance();
    for(iterator->begin(); !iterator->isFinished(); iterator->next())
    {
        int id = iterator->currentKey();
        QVector<QStandardItem*> preparedRows = polygonData->getStandardItem(id);
        for(int i=0; i<preparedRows.count(); i++)
        {
            item->appendRow(preparedRows[i]);
        }
    }
}
